package a日常研究._03java线程._01生产者消费者模型.base;

import a日常研究._03java线程._01生产者消费者模型.entity.Product;

import java.util.ArrayList;
import java.util.List;

public class BasePCModel {
    protected final int FULL_NUM = 10;
    protected List<Product> queue = new ArrayList<>(FULL_NUM);
    protected int serialNo = 1;

    protected void produce() throws InterruptedException{
        Product product = new Product("第" + serialNo + "个产品");
        queue.add(product);
        System.out.println(Thread.currentThread().getName() + "生产" + product.name);
        Thread.sleep(500);
        serialNo++;
    }

    protected void consume() throws InterruptedException{
        Product product = queue.remove(0);
        System.out.println(Thread.currentThread().getName() + "消费" + product.name);
        Thread.sleep(500);
    }
}
